<template>
    <div id="AsnDetail">
        <div class="detail">
            <!-- <v-navMenu
                     :detailNav="detailNav"
                     :menuData="menuData"
                     @setMentActive="setMentActive"
             ></v-navMenu>-->
            <component :inputData="detailData" :is="currentComponent"></component>
        </div>
    </div>

</template>

<script>
    import detail from "commons/Detail";
    import navMenu from "commons/NavMenu";
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "Detail",
        mixins: [baseMixin],
        data() {
            return {
                newFlag: true,
                selectData: {},
                detailData: {
                    cost_amt: 0,
                    total_basis: 0
                },
                detailNav: "1",
                temporary: {},
                /*menuData: [
                    {label: this.$t('common.detail'), index: "1"},
                ],*/
                componentConfig: [
                    {
                        name: "GatherDetail",
                        label: this.$t('common.info'),
                        component: () => import('./page/particulars.vue')
                    },
                ]
            }
        },
        computed: {
            currentComponent() {
                return this.componentConfig[this.detailNav - 1].component;
            }
        },
        methods: {
            setMentActive(key) {
                this.detailNav = key;
            },
            async getData() {
                try {
                    let res = await this.$api.get(`/queryCostByCode/${this.$store.state.wms}/${this.selectData.cost_no}`);
                    
                        this.detailData = res.bean;
                    
                } catch (e) {
                    this.$message.error(e);
                }
            },
        },
        mounted() {
            this.newFlag = this.$store.state.newFlag;
            //判断是否事新建
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.detailData = data.detail;
                this.selectData = data.routeData;
                this.detailNav = data.detailNav;
            } else if (this.newFlag) {

            } else {
                this.selectData = this.$store.state.routeData;
                this.getData();
            }

        },
        components: {
            "v-detail": detail,
            "v-navMenu": navMenu,
        },

    }
</script>

<style scoped>

</style>
